﻿using System;
using System.Web.UI.WebControls;

namespace HospitalManager.Site
{
    public partial class Index : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack) return;
            if (Session["username"] == null)
            {
                Response.RedirectToRoute("DangNhap");
            }
            else
            {
                LoadCombobox();
            }
        }

        private void LoadCombobox()
        {
            ddlTaiKhoan.Items.Add(new ListItem(Session["username"].ToString().Trim(), "0"));
            ddlTaiKhoan.Items.Add(new ListItem("Thông tin cá nhân", "1"));
            ddlTaiKhoan.Items.Add(new ListItem("Đăng xuất", "2"));
        }

        protected void ddlTaiKhoan_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (ddlTaiKhoan.SelectedValue)
            {
                case "1":
                    Response.RedirectToRoute("ThongTinBenhNhan");
                    break;
                case "2":
                    Session.Abandon();
                    Response.RedirectToRoute("DangNhap");
                    break;
            }
        }
    }
}